﻿@using GraduationProject.Model;
@using GraduationProject.Webs;
@{
    Layout = null;
    var UserModel = ViewData["UserModel"] as User;
    var NovelList = ViewData["TopModel"] as List<Novel>;
    var SortModel = ViewData["SortModel"] as List<SortList>;
}

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>孤独的旅行家</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link href="~/Content/layui/css/layui.css" rel="stylesheet" />
    <link href="~/Content/css/global2.css" rel="stylesheet" />
    <script src="~/Content/js/hm.js"></script>
</head>
<body>
    <!-- 头部 -->
    <div class="fly-header layui-bg-blue">
        <div class="layui-container">
            <a class="fly-logo" href="/Home/Index">
                <img src="~/Content/layui/images/logo.png" alt="layui">
            </a>
            <ul class="layui-nav fly-nav layui-hide-xs">
                <li class="layui-nav-item">
                    <a href="/Home/MapPage"><i class="iconfont icon-jifen"></i>地图</a>
                </li>
                <li class="layui-nav-item">
                    <a href="/Admin/AdminLogin/AdminLogin"><i class="iconfont icon-iconmingxinganli"></i>后台</a>
                </li>
                <span class="layui-nav-bar"></span>
            </ul>

            @if (UserModel != null)
            {
                <ul class="layui-nav fly-nav-user">
                    <li class="layui-nav-item">
                        <a class="fly-nav-avatar" href=""><img src="@UserModel.HeadPortrait" class="layui-nav-img">@UserModel.UserName</a>
                        <dl class="layui-nav-child">
                            <dd><a href="/Novel/InsertNovel">发表文章</a></dd>
                            <dd><a href="/UserInfo/UpDatePW">修改密码</a></dd>

                            <dd><a href="/UserInfo/LoginPage">退出</a></dd>
                        </dl>
                    </li>
                </ul>
            }
            else
            {
                <ul class="layui-nav fly-nav-user">
                    <!-- 未登入的状态 -->
                    <li class="layui-nav-item">
                        <a class="iconfont icon-touxiang layui-hide-xs" href="/UserInfo/LoginPage"></a>
                    </li>
                    <li class="layui-nav-item">
                        <a href="/UserInfo/LoginPage">登入</a>
                    </li>
                    <li class="layui-nav-item">
                        <a href="/UserInfo/RegistrationPage">注册</a>
                    </li>
                    <span class="layui-nav-bar"></span>
                </ul>
            }
        </div>
    </div><!-- 头部 end -->
    <!-- column -->
    <div class="fly-panel fly-column">
        <div class="layui-container">
            <ul class="layui-clear">
                <li><a href="/Home/Index">首页</a></li>
                @if (SortModel != null)
                {
                    foreach (var item in SortModel)
                    {
                        <li><a href="/Novel/SelectNovelByType?type=@item.SortID">@item.SortName</a></li>
                    }
                }
            </ul>
        </div>
    </div>
    <div class="layui-container">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md8">
                <div class="fly-panel">
                    <div class="fly-panel-title fly-filter">
                        <a>置顶</a>
                    </div>
                    <ul class="fly-list">
                        @if (NovelList != null)
                        {
                            foreach (var item in NovelList)
                            {
                                <li>
                                    <h2>
                                        <a class="layui-badge">@item.SortTypeName</a>
                                        <a href="/Comment/Index?NovelID=@item.NovelID">@item.NovelTitle</a>
                                    </h2>
                                    <div class="fly-list-info">
                                        <span>@item.NovelSummary</span>
                                        <span class="fly-list-kiss layui-hide-xs" title=">@(item.AgreeNum+ "点赞数")"><i class="iconfont icon-jifen"></i>@(item.AgreeNum + "点赞数")</span>
                                        <span class="fly-list-nums">
                                            <i class="iconfont icon-pinglun1" title="人气">@item.ClickNum</i>
                                        </span>
                                    </div>
                                    <div class="fly-list-badge">
                                        <span class="layui-badge layui-bg-black">置顶</span>
                                    </div>
                                </li>
                            }
                        }
                    </ul>
                </div>
                <div class="fly-panel" style="margin-bottom: 0;">
                    <!---文章遍历开始--->
                    <div class="fly-panel-title fly-filter">
                        <span class="fly-filter-right layui-hide-xs">
                            <a href="/Novel/TypeIndex?type=4">按最新</a>
                            <span class="fly-mid"></span>
                            <a href="/Novel/TypeIndex?type=3">按热度</a>
                        </span>
                    </div>
                    <ul class="fly-list" id="Table"></ul>
                    <div style="text-align: center">
                        <div id="test1"></div>
                    </div>
                </div>
            </div>
            <div class="layui-col-md4">
                @if (UserModel != null)
                {
                    <div class="layui-row layui-hide-xs">
                        <div class="layui-col-md12">
                            <div class="fly-panel" pad20="" style="padding-top: 5px;">
                                <div class="fly-home fly-panel" style="background-image: url();">
                                    <img src="@UserModel.HeadPortrait" alt="@UserModel.UserName">
                                    <i class="iconfont icon-renzheng" title="@UserModel.UserName"></i>
                                    <h1>
                                        <span class="local-name">@UserModel.UserName</span>
                                        <i class="layui-badge fly-badge-vip">@(UserModel.IsAdmin == 1 ? "管理员" : "普通用户")</i>
                                    </h1>
                                    <p style="padding: 10px 0; color: #5FB878;">邮箱信息：@UserModel.UserEmail</p>
                                    <p class="fly-home-info">
                                        <i class="iconfont icon-shijian"></i><span>@UserModel.UserPhone</span>
                                    </p>
                                    <p class="fly-home-sign">（踏踏实实，一步一个脚印）</p>
                                    <div class="fly-sns" data-user="">
                                        <a href="/Novel/SelectNovelByUserId?UserID=@UserModel.UserID" class="layui-btn layui-btn-primary fly-imActive" data-type="addFriend">访问文章</a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                }
                <dl class="fly-panel fly-list-one" id="HotTable"></dl>
                <div class="fly-panel">
                    <div class="fly-panel-title">
                        广告区域
                    </div>
                    <div class="fly-panel-main">
                        <a href="#" target="_blank" class="fly-zanzhu" time-limit="2017.09.25-2099.01.01" style="background-color: #5FB878;">孤独的旅行家--旅行必备</a>
                    </div>
                </div>
                <div class="fly-panel fly-link">
                    <h3 class="fly-panel-title">友情链接</h3>
                    <dl class="fly-panel-main">
                        <dd><a href="http://www.12306.cn/mormhweb/" target="_blank">12306</a></dd>
                        <dd>
                        </dd>
                        <dd><a href="http://www.ctrip.com/" target="_blank">携程</a></dd>
                        <dd>
                        </dd>
                        <dd><a href="https://www.fliggy.com/" target="_blank">飞猪</a></dd>
                        <dd>
                        </dd>
                        <dd><a href="https://www.qunar.com" target="_blank">去哪儿</a></dd>
                        <dd>
                        </dd>
                        <dd><a href="javascript:;" class="fly-link">申请友链qqming@126.com</a></dd>
                        <dd>
                        </dd>
                    </dl>
                </div>
            </div>
        </div>
    </div>
    <!-- 低部 -->
    <div class="fly-footer">
    </div>

    <script src="~/Content/layui/layui.js"></script>
    <script type="text/javascript">
        layui.use(['laypage', 'jquery', 'element'], function () {
            var laypage = layui.laypage, $ = layui.jquery, element = layui.element;
            element.on('nav(filter)', function (elem) {
                $(elem).find('dl').attr('class', 'layui-nav-child layui-anim layui-anim-upbit');
            });
            $(function () {
                LoadNovel(1, 10);
            });
            function LoadNovel(curr, limit) {
                var params = {
                    curr: curr,
                    limit: limit
                }
                $.ajax({
                    type: "post",
                    url: "/Home/GetNovelByPage",
                    data: params,
                    dataType: "json",
                    success: function (res) {
                        if (res.code == 0) {
                            //渲染数据
                            var Content = "";
                            $(res.data).each(function (n, Row) {
                                Content += `<li><h2><a class="layui-badge">${Row.SortTypeName}</a>
                                                                                    <a href="/Comment/Index?NovelID=${Row.NovelID}">${Row.NovelTitle}</a></h2>
                                                                                <div class="fly-list-info">
                                                                                    <span>${Row.NovelSummary}</span>
                                                                                    <span class="fly-list-kiss layui-hide-xs" title="点赞数"><i class="iconfont icon-jifen"></i>${Row.AgreeNum}</span>
                                                                                    <span class="fly-list-nums">
                                                                                        <i class="iconfont icon-pinglun1" title="人气"></i>${Row.ClickNum}
                                                                                    </span>
                                                                                </div>
                                                                                <div class="fly-list-badge">
                                                                                    <span class="layui-badge layui-bg-orange">精帖</span>
                                                                                </div>
                                                                            </li>`
                            })
                            $("#Table").html(Content);
                            //渲染分页
                            laypage.render({
                                elem: 'test1'
                                , count: res.count //数据总数，从服务端得到
                                , curr: curr
                                , limit: limit
                                , jump: function (obj, first) {
                                    if (!first) {
                                        LoadNovel(obj.curr, obj.limit);
                                    }
                                }
                            });
                        }
                        else {
                            layer.msg(res.msg, { icon: 2 });
                        }
                    }
                });
                $.ajax({
                    type: "post",
                    url: "/Novel/GetNovelByHot",
                    dataType: "json",
                    success: function (res) {
                        if (res.code == 0) {
                            //渲染数据
                            var Content = "";
                            Content += "<dt class='fly-panel-title'>热门帖子</dt>"
                            $(res.data).each(function (n, Row) {
                                Content += `
                                                    <dd>
                                                        <a href="/Comment/Index?NovelID=${Row.NovelID}" class="fly-link">${Row.NovelTitle}</a><a href="/Comment/Index?NovelID=${Row.NovelID}">${Row.NovelSummary}</a>
                                                        <span>${Row.AgreeNum}  点击量</span>
                                                    </dd>`
                            })
                            $("#HotTable").html(Content);
                        }
                        else {
                            layer.msg(res.msg, { icon: 2 });
                        }
                    }
                });
            }
        });
        function SwicthNum(num) {
            switch (num) {
                case 0:
                    return "攻略";
                case 1:
                    return "心得";
                case 2:
                    return "分享";
                case 3:
                    return "游记";
                default:
                    return "其他";
            }
        }

    </script>
    <span id="cnzz_stat_icon_30088308"></span>
    <ul class="layui-fixbar"><li class="layui-icon" lay-type="bar1" style="background-color:#009688"></li><li class="layui-icon layui-fixbar-top" lay-type="top" style="background-color:#009688"></li></ul>
</body>
</html>